lib: Fix a leak in remote parsing
authorColin Walters <walters@verbum.org>
Wed, 11 May 2016 17:32:40 +0000 (13:32 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 9 Jun 2016 21:10:35 +0000 (21:10 +0000)
As the docs say, `g_regex_match()` still allocates a match even if it
returns `FALSE`.  Using `g_autoptr` is just plain better.

Closes: #292
Approved by: krnowak

src/libostree/ostree-repo.c

index 0cff64e9a35f13f71253c8b0ee5c75413829dee8..f32a481595102cd4cce215c55e63bc2f5d253f26 100644 (file)
@@ -130,7 +130,7 @@ static OstreeRemote *
 ost_remote_new_from_keyfile (GKeyFile    *keyfile,
                              const gchar *group)
 {
-  GMatchInfo *match = NULL;
+  g_autoptr(GMatchInfo) match = NULL;
   OstreeRemote *remote;
 
   static gsize regex_initialized;
@@ -157,8 +157,6 @@ ost_remote_new_from_keyfile (GKeyFile    *keyfile,
 
   ot_keyfile_copy_group (keyfile, remote->options, group);
 
-  g_match_info_unref (match);
-
   return remote;
 }